<#assign object = doc.object>
package ${object.@package}.service.http;

import ${object.@package}.service.base.${object.@name}ServletBase;

/**
* Dispatcher for http/JSON requests for the web.
* This servlet will deploy all possible actions on your data (for example delete) without any restrictions.
* You can add security here.
* The Redora generated methods are in ${object.@name}ServletBase
* @see ${object.@name}ServletBase
* @author Redora (www.redora.net)
*/ 
public class ${object.@name}Servlet extends ${object.@name}ServletBase {

//Example of a simple security override
/*
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        //Try to have all custom activity use a standard parameter, like _operationType
        if (req.getParameter("_operationType") == null) {
            //Here you can override the default actions, for this example
            //we let everything through
            super.doGet(req, resp);
        } else {
            //First get the handy JSONWriter
            JSONWriter writer = new JSONWriter(resp.getWriter());

            //Note that you can use:
            //Page page = the page(req);
            //if paging is part of the request.
            ${object.@name}Service service = null;
            ${object.@name}Service serviceJSON = null;
            try {
                ${object.@name}Service service = ServiceFactory.${object.@name?uncap_first}Service();
                ${object.@name}ServiceJSON serviceJSON = ServiceFactory.${object.@name?uncap_first}ServiceJSON();
                if (req.getParameter("action").equalsIgnoreCase("remove")) {
                    ${object.@name} ${object.@name?uncap_first} = serviceJSON.fromJson(${object.@name}Util.getJSONValue(req));
                    //just an example...
                    if (RandomUtils.nextBoolean()) {
                        writer.persist(service.delete(${object.@name?uncap_first}));
                        //Sends out the standard 'success' message wrapped in JSON, or when any business rules
                        //got violated, wraps the business rules in JSON and returns those on the output stream.
                    }
                }
            } catch (Exception e) {
                l.log(Level.SEVERE, "I failed to process a JSON request: " + req.getParameter("action"), e);
                throw new ServletException("I failed to process a JSON request: " + req.getParameter("action"), e);
            } finally {
                ServiceFactory.close(service);
                ServiceFactory.close(serviceJSON);
            }
        }
    }
*/
}
